<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
include_once("../../config.inc.php");

$_LangPath = "usercredit";	//語言檔參數，務必放在最前面
include_once(__Admin_Path."/logincheck.php");
include_once(__Language_Path."/selectlanguage_admin.php");
include_once(__Modules_Path."/Member.lib.php");

$strType = trim($_data["Type"]);
$strData = "";
$strMType = "";
$strMData = "";
switch($strType){
	case "SkypeAcc":
		$arrD["SkypeAcc"] = trim($_data["SkypeAcc"]);
		$strData = $arrD["SkypeAcc"];
		$strMData = $arrD["SkypeAcc"];
		$strMType = "skype";
		break;

	case "Email":
		$arrD["Email"] = trim($_data["Email"]);
		$strData = $arrD["Email"];
		$strMData = $arrD["Email"];
		$strMType = "email";
		break;

	case "MSN":
		$arrD["MSN"] = trim($_data["MSN"]);
		$strData = $arrD["MSN"];
		$strMData = $arrD["MSN"];
		$strMType = "msn";
		break;

	case "QQNum":
		$arrD["QQNum"] = trim($_data["QQNum"]);
		$strData = $arrD["QQNum"];
		$strMData = $arrD["QQNum"];
		$strMType = "qq";
		break;

	case "MPhone":
		$_data["MPhone"] = trim($_data["MPhone"]);
		$_data["MPhone"] = preg_replace("/^0*/", "", $_data["MPhone"]);
		if($_data["MPhone"] == ""){
			$arrD["MPhone"] = trim($_data["Area"])."-".$_data["MPhone"];
			$strData = "+".trim($_data["Area"])." ".$_data["MPhone"];
			$strMData = "+".trim($_data["Area"])."".$_data["MPhone"];
		}else{
			$arrD["MPhone"] = "";
			$strData = "";
			$strMData = "";
		}
		$strMType = "sms";
		break;
}

//更改使用者資料
if(!setUserData($_SESSION["Admin_Info"] -> ID, $_SESSION["Admin_Info"] -> ID, $_SESSION["Admin_Info"] -> MemberGroup, $arrD))ErrMsgOutputHTML("Error1", "RebackError", 1);

if($strMData != ""){
	$strAuthCode = getAuthCode();
	//設定認證碼
	if(!setUserAuthCode($_SESSION["Admin_Info"] -> ID, $strType, $strAuthCode))ErrMsgOutputHTML("Error2", "RebackError", 1);
	//發送認證碼
	if(!sendUserAuthCode($_SESSION["Admin_Info"] -> Account, $strMType, $strMData, $strAuthCode))ErrMsgOutputHTML("Error3", "RebackError", 1);
}

$GLOBALS["errormessage"] = $_strUserCredit["CommSuccess"];
//ErrMsgOutputHTML("Success", "", 1);
?><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title> Success </title>
<script language="JavaScript">
<!--
var strType = "<?php print $strType;?>";
alert("<?php print $GLOBALS["errormessage"];?>");
parent.document.getElementById(strType + "Data").innerHTML = "<?php print $strData;?>";
parent.document.getElementById(strType + "Auth").disabled = false;
parent.document.getElementById(strType + "CheckStatus").innerHTML = "<div style='color: #FF0000; font-weight: 700'><?php print $_strUserCredit["NoAuth"];?></div>";
//-->
</script>
</head>
</html>